package bill.study.enums.effectivejava.item30;

public enum PayrollDay {
	MONDAY(PayType.WEEKDAY), 
	TUESDAY(PayType.WEEKDAY), 
	WEDNESDAY(PayType.WEEKDAY), 
	THURSDAY(PayType.WEEKDAY), 
	FRIDAY(PayType.WEEKDAY), 
	SATURDAY(PayType.WEEKDAY), 
	SUNDAY(PayType.WEEKDAY);
	private final PayType payType;
	PayrollDay(PayType payType){
		this.payType = payType;
	}
	
	private enum PayType{
		WEEKDAY {
			@Override
			double overtimePay(double hrs, double payrate) {
				return hrs<= HOURS_PER_SHIFT ?0:
					(hrs -HOURS_PER_SHIFT) * payrate/2;
			}
		},
		WEEKEND {
			@Override
			double overtimePay(double hrs, double payrate) {
				return hrs * payrate/2;
			}
		};
		
		private static final int HOURS_PER_SHIFT = 8;
		abstract double overtimePay(double hrs, double payrate);
		double pay(double hoursWorked, double payRate){
			double basePay = hoursWorked * payRate;
			return basePay + overtimePay(hoursWorked, payRate);
		}
	}

}
